<?php


namespace api\blog\model;


use think\Model;

class GoodsModel extends Model
{
    protected $name = 'goods';
    protected $autoWriteTimestamp = 'Y-m-d H:i:s';
    //获取图片
    public function getPhotosUrlAttr($value){
        $images = explode(',',$value);
        foreach($images as $key => $value){
            $images[$key] = cmf_get_image_url($value);
        }
        return $images;
    }
    //显示状态
//    public function getStatusAttr($value){
//        $status = [0=>'隐藏',1=>'显示'];
//        return $status[$value];
//    }
    //自营状态
    public function getSourceAttr($value){
        $status = [0=>'否',1=>'是'];
        return $status[$value];
    }
    //关联分类表
    public function classify(){
        return $this->hasOne(ClassifyModel::class,'id','gid')->field('id,title');
    }
}